<template>
  <div>
    <h2>我是App组件</h2>
    <p>{{count}}</p>

    <!-- <Child @changeCount="changeCount"/> -->
    <Child ref="childComp"/>
  </div>
</template>

<script>
import Child from '@/components/Child'
export default {
  name: "App",
  components: {
    Child
  },
  data(){
    return({
      count:0
    })
  },
  mounted() {
     this.$refs.childComp.$once("changeCount", this.changeCount);
    // this.$refs.childComp.$on("changeCount", this.changeCount);
  },
  methods:{
    changeCount(value){
      this.count += value
    }
  }
};
</script>

<style>

</style>
